package cn.itcast.item.comfig;


import cn.itcast.item.constants.MqConstants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class Mq {
    @Bean
    public TopicExchange topicExchange() {
        return new TopicExchange(MqConstants.HMALL_EXCHANGE, true, false);
    }

    @Bean
    public Queue addQueue() {
        return new Queue(MqConstants.HMALL_add_QUEUE,true);
    }

    @Bean
    public Queue deleteQueue() {
        return new Queue(MqConstants.HMALL_DELETE_QUEUE, true);
    }

    @Bean
    public Binding exchangbaddq() {
        return BindingBuilder.bind(addQueue()).to(topicExchange()).with(MqConstants.HMALL_INSERT_KEY);
    }
    @Bean
    public Binding exchangbdeleteq() {
        return BindingBuilder.bind(deleteQueue()).to(topicExchange()).with(MqConstants.HMALL_INSERT_KEY);
    }

}
